<#include "dictionary.html"/>
<#macro input name extend index value='' type='form' safe=true itemType='' itemId=''>
    <#local inputName=name+'['+index+'].value'/>
        <input name="${name}[${index}].name" type="hidden" value="${extend.id.code}"/>
    <#switch extend.inputType>
        <#case 'number'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
        <input name="${inputName}" <#if 'customform'!=type>class="number<#if extend.required> required</#if>" </#if>type="number"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> value="${(value)!}"/>
            </#if>
            <#break>
        <#case 'file'>
            <#if 'view'=type>
                <a href="${getUrl(value)!}" target="_blank">${(value)!}</a>
            <#else>
        <input name="${inputName}" <#if 'customform'!=type>class="<#if extend.required>required</#if>" type="text" maxlength="300" size="50" <#else>type="file" </#if>value="${(value)!}"/>
                <#if 'customform'!=type>
                    <a class="btnAttach" href="common/upload.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="600"><@t.page 'attach'/></a>
                    <a class="view icon-eye-open" ref="${inputName}" data-prefix="${site.sitePath}" href="javascript:void(0);" target="_blank"><@t.page 'button.view'/></a>
                </#if>
            </#if>
            <#break>
        <#case 'image'>
            <#if 'view'=type>
                <img src="${getUrl(value)!}" style="max-width:200px;max-height:200px;"/>
                <br/>
                ${(value)!}
            <#else>
        <input name="${inputName}" size="50" <#if 'customform'!=type>class="<#if extend.required>required</#if>" type="text" maxlength="300" size="50" <#else>type="file" accept="image/*" </#if>value="${(value)!}"/>
                <#if 'customform'!=type>
                    <a class="btnAttach" href="common/upload.html?field=value&fileTypes=image&width=${extend.width!}&height=${extend.height!}" lookupGroup="${name}[${index}]" width="1000" height="600"><@t.page 'image'/></a>
                    <a class="view icon-eye-open" ref="${inputName}" data-prefix="${site.sitePath}" href="javascript:void(0);" target="_blank"><@t.page 'button.view'/></a>
                    <#if (extend.width)?has_content && (extend.height)?has_content><span class="info">${extend.width!}*${extend.height!}</span></#if>
                    <#if !preview?has_content>
                        <#include "../include_page/preview.html"/>
                    </#if>
                    <@preview extend.id.code 'input[name="${inputName}"]' ''/>
                </#if>
            </#if>
            <#break>
        <#case 'video'>
            <#if 'view'=type>
                <video controls="controls" src="${getUrl(value)!}" style="max-width:500px;max-height:500px;"></video>
                <br/>
                ${(value)!}
            <#else>
        <input name="${inputName}" <#if 'customform'!=type>class="<#if extend.required>required</#if>" type="text" maxlength="300" size="50" <#else>type="file" accept="video/*"</#if>value="${(value)!}"/>
                <#if 'customform'!=type>
                    <a class="btnAttach" href="common/upload.html?field=value&fileTypes=video" lookupGroup="${name}[${index}]" width="1000" height="600"><@t.page 'video'/></a>
                    <a class="view icon-eye-open" ref="${inputName}" data-prefix="${site.sitePath}" href="javascript:void(0);" target="_blank"><@t.page 'button.view'/></a>
                </#if>
            </#if>
            <#break>
        <#case 'password'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
        <input name="${inputName}"<#if extend.maxlength?has_content> size="${extend.maxlength}" maxlength="${extend.maxlength}"<#else> size="30"</#if> <#if 'customform'!=type>class="<#if extend.required> required</#if>" </#if>type="password" value="${(value)!}"/>
            </#if>
            <#break>
        <#case 'textarea'>
            <#if 'view'=type>
                <pre>${(value)!}</pre>
            <#else>
        <textarea name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> <#if 'customform'!=type>class="<#if extend.required>required</#if>" </#if>cols="80" rows="4">${(value)!}</textarea>
            </#if>
            <#break>
        <#case 'editor'>
        <#case 'ckeditor'>
        <#case 'tinymce'>
        <#case 'kindeditor'>
            <#if 'view'=type>
                <#if safe>${(value?no_esc)!}<#else>${value!}</#if>
            <#else>
                <#if 'customform'!=type>
                    <div>
                        <a class="button" href="common/import.html?fieldName=extend.${extend.id.code}&field=value" lookupGroup="${name}[${index}]" width="500" height="300"><@t.page 'import_doc'/></a>
                        <#if itemType?has_content && itemId?has_content>
                            <a class="button" href="cmsEditorHistory/lookup.html?itemType=${itemType}&itemId=${itemId?url}&fieldName=${extend.id.code}" lookupGroup="${name}[${index}]"><@t.page 'history'/></a>
                        </#if>
                    </div>
                </#if>
        <textarea name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> <#if 'customform'!=type>class="editor<#if extend.required> required</#if>" editorType="${extend.inputType}" </#if>cols="80" rows="20">${(value)!}</textarea>
            </#if>
            <#break>
        <#case 'template'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> type="text" maxlength="255" size="50" value="${(value)!}"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsTemplate/lookup.html?field=value" lookupGroup="${name}[${index}]"><@t.page 'template.select'/></a>
            </#if>
            <#break>
        <#case 'boolean'>
            <#if 'view'=type>
                <#if value?has_content>${('true'=value)?then(t.pageMessage('yes'),t.pageMessage('no'))}</#if>
            <#else>
        <select<#if 'customform'!=type> class="combox<#if extend.required> required</#if>"</#if> name="${inputName}">
            <option value><@t.page 'all'/></option>
            <option value="true"${(value?has_content&&'true'=value)?then(' selected="true"','')?no_esc}><@t.page 'yes'/></option>
            <option value="false"${(!value?has_content||'false'=value)?then(' selected="true"','')?no_esc}><@t.page 'no'/></option>
        </select>
            </#if>
            <#break>
        <#case 'user'>
            <@sys.user id=value><#local u=object/></@sys.user>
            <#if 'view'=type>
                ${(value)!}:${(u.nickname)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].nickname" readonly="readonly" size="30" value="${(u.nickname)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="sysUser/lookup.html?field=value" width="1200" height="580" lookupGroup="${name}[${index}]"><@t.page 'user.select'/></a>
            </#if>
            <#break>
        <#case 'dept'>
            <@sys.dept id=value><#local d=object/></@sys.dept>
            <#if 'view'=type>
                ${(value)!}:${(d.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].deptName" readonly="readonly" size="30" value="${(d.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="sysDept/lookup.html?field=value" width="920" lookupGroup="${name}[${index}]"><@t.page 'dept.select'/></a>
            </#if>
            <#break>
        <#case 'content'>
            <@cms.content id=value><#local tempContent=object/></@cms.content>
            <#if 'view'=type>
                ${(value)!}:${(tempContent.title)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].title" readonly="readonly" size="30" value="${(tempContent.title)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsContent/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'content.select'/></a>
            </#if>
            <#break>
        <#case 'category'>
            <@cms.category id=value><#local tempCategory=object/></@cms.category>
            <#if 'view'=type>
                ${(value)!}:${(tempCategory=object.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].categoryName" readonly="readonly" size="30" value="${(tempCategory.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsCategory/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'category.select'/></a>
            </#if>
            <#break>
        <#case 'categoryType'>
            <@cms.categoryType id=value><#local categoryType=object/></@cms.categoryType>
            <#if 'view'=type>
                ${(value)!}:${(categoryType.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].categoryTypeName" readonly="readonly" size="30" value="${(categoryType.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsCategoryType/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'select'/></a>
            </#if>
            <#break>
        <#case 'tagType'>
            <@cms.tagType id=value><#local tagType=object/></@cms.tagType>
            <#if 'view'=type>
                ${(value)!}:${(tagType.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].tagTypeName" readonly="readonly" size="30" value="${(tagType.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsTagType/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'select'/></a>
            </#if>
            <#break>
        <#case 'tag'>
            <@cms.tag id=value><#local tag=object/></@cms.tag>
            <#if 'view'=type>
                ${(value)!}:${(tag.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].tagName" readonly="readonly" size="30" value="${(tag.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsTag/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'select'/></a>
            </#if>
            <#break>
        <#case 'vote'>
            <@cms.vote id=value><#local vote=object/></@cms.vote>
            <#if 'view'=type>
                ${(value)!}:${(vote.title)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].voteName" readonly="readonly" size="30" value="${(vote.title)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsVote/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'select'/></a>
            </#if>
            <#break>
        <#case 'survey'>
            <@cms.survey id=value><#local survey=object/></@cms.survey>
            <#if 'view'=type>
                ${(value)!}:${(survey.title)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].surveyName" readonly="readonly" size="30" value="${(survey.title)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsSurvey/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'select'/></a>
            </#if>
            <#break>
        <#case 'dictionary'>
            <@cms.dictionary id=extend.dictionaryId><#local dictionary=object/></@cms.dictionary>
            <#if dictionary?has_content>
                <#if 'view'=type>
                    <@cms.dictionaryData dictionaryId=extend.dictionaryId values=value><#list map as k,data>${data.text}<#sep>,</#list></@cms.dictionaryData>
                <#else>
                    <#local inputValuesName=name+'['+index+'].values'/>
                    <#local dictionaryId='dictionary_'+.now?long/>
                    <#if 'customform'=type>
        <@dictionaryElement extend.dictionaryId inputValuesName extend.required dictionary.childDepth extend.multiple type value/>
                    <#else>
                        <div class="dictionary" data-id="${dictionary.id.id}" data-ref="<@cms.dictionaryExcludeList dictionaryId=dictionary.id.id><#list list as a>${a.id.excludeDictionaryId}<#sep>,</#list></@cms.dictionaryExcludeList>" data-url="common/dictionaryExclude.html" id="${dictionaryId}">
                           <@dictionaryElement extend.dictionaryId inputValuesName extend.required dictionary.childDepth extend.multiple type value/>
                        </div>
                    </#if>
                    <#if 'customform'!=type>
                        <@sys.authorized roleIds=admin.roles url='cmsDictionary/add'>
                            <a href="common/dictionary.html?id=${dictionary.id.id}&inputName=inputValuesName&required=${extend.required!}&multiple=${extend.multiple!}&value=${value!}" target="ajax" rel="${dictionaryId}"><i class="icon-refresh"></i><@t.page 'button.refresh'/></a>
                            <#if dictionary.childDepth gt 0>
                                <a href="cmsDictionary/addChild.html?id=${dictionary.id.id}" target="dialog" mask="true" icon="<i class='icon-edit'></i>"><@t.page 'dictionary.edit'/></a>
                            <#else>
                                <a href="cmsDictionary/add.html?id=${dictionary.id.id}" target="navTab" rel="cmsDictionary/edit" icon="<i class='icon-edit'></i>"><@t.page 'dictionary.edit'/></a>
                            </#if>
                        </@sys.authorized>
                    </#if>
                </#if>
            </#if>
            <#break>
        <#case 'date'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}" <#if 'customform'!=type>class="date<#if extend.required> required</#if>" autocomplete="off" dateFmt="yyyy-MM-dd" </#if>type="text" size="10" value="${(value)!}"/>
                <#if 'customform'!=type><a class="inputDateButton" href="javascript:void(0);"></a></#if>
            </#if>
            <#break>
        <#case 'datetime'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
        <input name="${inputName}" <#if 'customform'!=type>class="date<#if extend.required> required</#if>" autocomplete="off" dateFmt="yyyy-MM-dd HH:mm:ss" </#if>type="text" size="20" value="${(value)!}"/>
                <#if 'customform'!=type><a class="inputDateButton" href="javascript:void(0);"></a></#if>
            </#if>
            <#break>
        <#case 'color'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
        <input name="${inputName}" <#if 'customform'!=type>class="color<#if extend.required> required</#if>" autocomplete="off" </#if>type="text" size="20" value="${(value)!}"/>
            </#if>
            <#break>
        <#case 'alphaColor'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
        <input name="${inputName}" <#if 'customform'!=type>class="color<#if extend.required> required</#if>" autocomplete="off" showAlpha="true" </#if>type="text" size="20" value="${(value)!}"/>
            </#if>
            <#break>
        <#case 'categoryPath'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}" type="text" <#if 'customform'!=type><#if extend.required> class="required"</#if></#if> autocomplete="on" maxlength="500" size="100" value="${(value)!}"/>
                <a class="btnLook" href="cmsCategory/categoryPath.html?field=value" lookupGroup="${name}[${index}]" width="920"><@t.page 'select_path'/></a>
            </#if>
            <#break>
        <#case 'module'>
            <#if value?has_content>
                <#local values=value?split(',')/>
            </#if>
            <#if 'view'=type>
                <#if values?has_content>
                    <#list values as a><@t.menu a/><#sep>,</#list>
                </#if>
            <#else>
                <#list ["comment_list","tag_list","product_list","vote_list","survey_list","category_extend","trade_menu","page_diy","page_diy_preview","visit_menu","myself_device","app_client_list"] as a>
                    <label><input name="${inputName}" type="checkbox" value="${a}"${(values?has_content&&values?seq_contains(a))?then(' checked="true"','')?no_esc}/><@t.menu a/></label>
                </#list>
            </#if>
            <#break>
        <#case 'lang'>
            <#if value?has_content>
                <#local values=value?split(',')/>
            </#if>
            <#if 'view'=type>
                <#if values?has_content>
                    <#list values as a>${langs[a]}<#sep>,</#list>
                </#if>
            <#else>
                <#list langs as k,v>
                    <label><input name="${inputName}" type="checkbox" value="${k}"${(values?has_content&&values?seq_contains(k))?then(' checked="true"','')?no_esc}/>${v}</label>
                </#list>
            </#if>
            <#break>
        <#case 'captcha'>
            <#if value?has_content>
                <#local values=value?split(',')/>
            </#if>
            <#if 'view'=type>
                <#if values?has_content>
                    <#list values as a><@t.page a/><#sep>,</#list>
                </#if>
            <#else>
                <#list ["register","login","management_system","comment","contribute","upload","survey"] as a>
                    <label><input name="${inputName}" type="checkbox" value="${a}"${(values?has_content&&values?seq_contains(a))?then(' checked="true"','')?no_esc}/><@t.page a/></label>
                </#list>
            </#if>
            <#break>
        <#case 'contentStatus'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <select class="combox<#if extend.required> required</#if>" name="${inputName}">
                    <#list 0..2 as s>
                        <option value="${s}"${(value?has_content&&s?string=value)?then(' selected="true"','')?no_esc}><@t.page 'status.content.'+s/></option>
                    </#list>
                </select>
            </#if>
            <#break>
        <#default>
            <#if 'view'=type>
                ${(value)!}
            <#else>
        <input name="${inputName}"<#if extend.maxlength?has_content> size="${extend.maxlength}" maxlength="${extend.maxlength}"<#else> size="50"</#if> <#if 'customform'!=type>class="<#if extend.required> required</#if>" </#if>type="text" value="${(value)!}"/>
            </#if>
    </#switch>
</#macro>
<#macro extendData name extendList=[] extendValues={} historyItemType='' historyItemId='' type='form' htmlSafe=false>
    <#list extendList as e>
    <#local value=extendValues[e.id.code]!e.defaultValue!''/>
        <#if 'customform'=type>
    <p>
        <label>${(e.name)}:</label>
        <@input name e e?index value type/>
    </p>
        <#else>
    <dl<#if !['number','alphaColor','color','date','datetime','boolean','text','password']?seq_contains(e.inputType)> class="nowrap"</#if>>
        <dt>${(e.name)}:</dt>
        <dd<#if 'editor'=e.inputType> style="width:90%;"</#if>>
            <@input name e e?index value type htmlSafe historyItemType historyItemId/>
            <#if e.description?has_content><span class="info">${htmlSafe?then(e.description?no_esc,e.description)}</span></#if>
        </dd>
    </dl>
        </#if>
    </#list>
</#macro>